package com.duqc.web.service.impl;

import com.duqc.web.dao.TransactionalMapper;
import com.duqc.web.dto.TransactionalDTO;
import com.duqc.web.service.TransactionalService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName TransactionalServiceImpl
 * @Description TODO
 * @Author duqc
 * @Date 2021/5/8
 **/
@Slf4j
@Service
@RequiredArgsConstructor
public class TransactionalServiceImpl implements TransactionalService {

    private final TransactionalMapper transactionalMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<TransactionalDTO> addInfo() {
//        TransactionalDTO transactionalDTO = TransactionalDTO.builder()
//                .id(new Random().nextInt(1000000))
//                .name("测试")
//                .createTime(DateUtils.getNow()).build();
//        this.transactionalMapper.addInfo(transactionalDTO);
//        int a = 1/0;

        update();
        return null;
    }

//    @Transactional(rollbackFor = Exception.class)
    public void update(){
        this.transactionalMapper.update();
    }
}
